package jjn.round2;

/**
 * @author Jiang Jining
 * @since 2023-05-03 13:13
 */
public class Offer10_Fib {
    public int fib(int n) {
        int[] result = new int[n + 2];
        result[0] = 0;
        result[1] = 1;
        for (int i = 2; i <= n; i++) {
            result[i] = result[i - 1] + result[i - 2];
            if (result[i] > 1000000007) {
                result[i] = result[i] % 1000000007;
            }
        }
        return result[n];
    }
}
